<?php
/**
 * 系統名稱: Kacino 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
//$_data = ($_SERVER["REQUEST_METHOD"] == "GET")?$_GET:$_POST;
include_once("../config.inc.php");

$arrWeb = split(",", $_data["AllWeb"]);

$strTmp1 = "<tr>
	<td class='web-name'>{Web}</td>
	<td class='web-td'><!--Max_used_connections//-->0</td>
	<td class='web-td'><!--Connections//-->0</td>
	<td class='web-td'><!--Table_locks_immediate//-->0</td>
	<td class='web-td'><!--Table_locks_waited//-->0</td>
	<td class='web-td'><!--Threads_cached//-->0</td>
	<td class='web-td'><!--Threads_connected//-->0</td>
	<td class='web-td'><!--Threads_created//-->0</td>
	<td class='web-td'><!--Threads_running//-->0</td>
	<td class='web-td'><!--Slow_queries//-->0</td>
	<td class='web-td'><!--Queries per second avg//-->0</td>
</tr>";

$arrDB = array();
$strCon = "";
foreach($arrWeb as $strDomain){
	include("/home/share/www/".$strDomain."/secure/db.inc.php");
	if(!preg_match("/UTF8/i", $_blDBName))continue;

	$arrDB[$_blDBHostM][] = $strDomain;
	if(sizeof($arrDB[$_blDBHostM]) > 1)continue;

	$strTmp2 = $strTmp1;
	$strTmp2 = str_replace("{Web}", $_blDBHostM, $strTmp2);

	$strSQL = "SHOW STATUS;";
	$RS = @PMA_mysql_query($strSQL, $$_Conn);
	while($Rows = PMA_mysql_fetch_array($RS, MYSQL_ASSOC)){
		$strTmp2 = str_replace("<!--".$Rows["Variable_name"]."//-->0", $Rows["Value"], $strTmp2);
	}
	$status = explode('  ', mysql_stat($$_Conn));
	$status[7] = str_replace("Queries per second avg:", "", $status[7]);
	$strTmp2 = str_replace("<!--Queries per second avg//-->0", trim($status[7]), $strTmp2);
	$strCon .= $strTmp2;
	@mysql_free_result($RS);
	@mysql_close($$_Conn);
}

foreach($arrDB as $IP => $arrDomain){
	$arrIP = split("\.", $IP);
	$strTip = "<div title='".join(", ", $arrDomain)."'>DB".(string)($arrIP[3] % 100)."</div>";
	$strCon = str_replace($IP, $strTip, $strCon);
}
?><!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> DB Status </title>
<style>
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	font-size: 12px
	font-family: Arial, Helvetica, Verdana, Geneva,  sans-serif;
	background-color: #EFFFDF;
}
td {
	font-size: 12px
	font-family: Arial, Helvetica, Verdana, Geneva,  sans-serif;
	background-color: #FFFFFF;
	text-align: center;
}
.showTable {
	background-color: #9DBAD8;
	border: 1px solid #056FD8;
}
.web-td {
	text-align: right;
	padding-right: 2px;
}
.web-name {
	text-align: left;
	padding-left: 2px;
}
//-->
</style>
</head>

<body>
<table  border="0" cellspacing="1" cellpadding="0" class="showTable">
<tr>
	<td width="100">網站</td>
	<td width="70">MUS<a style="color: #FF0000">*</a></td>
	<td width="70">CS</td>
	<td width="70">TLI</td>
	<td width="70">TLW</td>
	<td width="70">TCa</td>
	<td width="70">TCo<a style="color: #FF0000">*</a></td>
	<td width="70">TCr</td>
	<td width="70">TRu</td>
	<td width="70">SQ</td>
	<td width="70">QPS<a style="color: #FF0000">*</a></td>
</tr>
<?php print $strCon;?>
</table>
現在時間：<?php print date("Y-m-d H:i:s");?><br /><br />
ps:<br />
MUS：Max_used_connections<br />
CS：Connections<br />
TLI：Table_locks_immediate<br />
TLW：Table_locks_waited<br />
TCa：Threads_cached<br />
TCo：Threads_connected<br />
TCr：Threads_created<br />
TRu：Threads_running<br />
SQ：Slow_queries<br />
QPS：Queries per second avg
</body>
</html>